<?php
namespace App\Controllers\Order;
use App\Models\Goods\Goods;
use App\Models\Order\Order;
use App\Models\Goods\GoodsAffiliate;
use App\Models\Store\Store;
use App\Libs\Order\OrderList;

/**
*	获取订单各状态数量
*/
class GetOrderStatus extends \App\Libs\Base\BaseAction
{
    protected function beforeRun() {
        parent::beforeRun();
        $this->needLogin = TRUE;
    }
	
	public function execute(){
		$user = $this->session->user;
		//获取信息
		$order = OrderList::orderStatusCount( $user );
		
		if( empty( $order ) ){
			return \App\Libs\Views\Json::view(0, '成功', [] );
		}else{
			$orderResult = [];
			foreach( $order as $k=>$v ){
				$orderResult[$v['status']] = $v['count'];
			}
			return \App\Libs\Views\Json::view(0, '成功', $orderResult );
		}
	}
}
